package servlet.servlet_yaobo;

import net.sf.json.JSONObject;
import service.impl.ImpShoppingMemberService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 用于删除购物车信息
 */
@WebServlet(value = "/deleteCart")
public class DeleteCart extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id=req.getParameter("id");
        ImpShoppingMemberService imp=new ImpShoppingMemberService();
        int index=imp.deleteCart(Integer.parseInt(id));
        JSONObject json=new JSONObject();
        json.put("data",index);
        PrintWriter out=resp.getWriter();
        out.println(json);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
